<?php declare(strict_types=1);


namespace App\Dao;


use App\Model\Student;

class StudentDao extends BaseDao
{
    /**
     * 通过学号查找
     * @param $num
     * @return \Hyperf\Database\Model\Builder|\Hyperf\Database\Model\Model|object|null
     */
    public function findByNum($num)
    {
        return Student::query()->where('stu_num', (string)$num)->first();
    }

    /**
     * 修改密码
     */
    public function editPassword(Student $student, $password)
    {
        $student->password = $password;
        return $student->save();
    }

    /**
     * 添加一个学生
     * @param array $params
     * @return mixed
     */
    public function addStu(array $params)
    {
        $student = new Student();
        return $this->saveOne($student, $params);
    }
}